<?php
if (isset($_GET['tit']) && trim($_GET['tit'])) {
    $tituloPagina = trim($_GET['tit']);
}
if (!isset($_GET['tit'])) {
    $tituloPagina = 'Home';
}
?>
<!doctype html>
<html>
    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <link rel="stylesheet" type="text/css" href="<?php echo cssPath ?>style.css" />

        <title>Kapilyar</title>

    </head>

    <body>
        <div id="geral">

            <div id="cabecalho"></div>


            <div id="logo">
                <img src="<?php echo imgPath ?>logo.png" class="logo">
            </div>


            <?php if ($user->isAuthenticated()): ?>

                <div id="login">
                    <img src="<?php echo imgPath ?>welcome.png">
                    Bem vindo,
                    <?php
                    echo $user->getData('firstname');
                    $id = $user->getData('iduser');
                    ?>

                    <img src="<?php echo imgPath ?>logoff.png">
                    <a href="/authentication/logout" class="btnLogoff">sair</a>
                </div>

                <div id="menu">
                    <ul class="menuItens" id="menuItens2">
                        <li><a class="iconHome" href="/?tit=Home"><span>Home</span></a></li>
                        <li><a class="iconPerfil" href="/cliente/perfil/?tit=Meu Perfil"><span>Meu Perfil</span></a></li>
                        <li><a class="iconHistorico" href="/historico/meusHistorico/?tit=Meus Históricos"><span>Meus Históricos</span></a></li>

                        <li><a class="iconContato" href="/home/contato/?tit=Contato"><span>Contato</span></a></li>
                    </ul>
                </div>

            <?php else: ?>

                <div id="login">    
                    <img  src="<?php echo imgPath ?>topoLogin.png">
                    <div class="corpoLogin"></div>

                    <form method="POST" action="/authentication/login" class="formLogin">

                        <label for="email">E-mail</label>
                        <input type="email" name="email" id="email" tabindex="1" placeholder="contato@kapilyar.com" maxlength="30" size="20" />

                        <label for="password">Senha</label>
                        <input type="password" name="password" id="password" tabindex="2" maxlength="8" size="10" />

                        <button type="submit" value="Entrar"  tabindex="3">Entrar</button>

                        <?php if (isset($_GET['error'])): ?>
                            <p class="error">E-mail e/ou senha inválidos!</p>
                        <?php endif; ?>

                    </form>
                </div>

                <div id="menu">
                    <ul class="menuItens" id="menuItens1">
                        <li><a class="iconHome" href="/?tit=Home"><span>Home</span></a></li>
                        <li><a class="iconSobre" href="/home/sobre/?tit=Sobre Kapilyar"><span>Sobre nós</span></a></li>
                        <li><a class="iconCadastro" href="/cliente/cadastro/?tit=Cadastre-se"><span>Cadastre-se</span></a></li>
                        <li><a class="iconReativar" href="/cliente/reativarPerfil/?tit=Reativar Perfil"><span>Reativar Conta</span></a></li>
                        <li><a class="iconContato" href="/home/contato/?tit=Contato"><span>Contato</span></a></li>
                    </ul>
                </div>
            <?php endif; ?>  

            <div id="barraConteudo">
                <div class="barraHistorico"><p><?php echo $tituloPagina; ?></p></div>
            </div>
            <!-- Area de conteudo -->
            <div id="content" class="conteudo">

                <?php include $view ?>

            </div>    


    </body>
</html>
